package com.gitee.ly.api;

import com.gitee.ly.ServiceManage;
import com.gitee.ly.model.FindBody;
import com.gitee.ly.model.JsonResult;
import com.gitee.ly.model.ServiceInfo;
import lombok.extern.slf4j.Slf4j;
import org.noear.solon.annotation.Body;
import org.noear.solon.annotation.Controller;
import org.noear.solon.annotation.Mapping;
import org.noear.solon.annotation.Post;

import java.util.List;

//服务发现/查询 API
@Slf4j
@Controller
public class FindApi {

    //查可用的
    @Post
    @Mapping(path = "/findCanUse")
    public JsonResult<List<ServiceInfo>> findCanUse(@Body FindBody body) {
        return JsonResult.result(ServiceManage.findCanUse(body.getName()), 200, "");
    }

    //查所有的
    @Post
    @Mapping(path = "/findAll")
    public JsonResult<List<ServiceInfo>> findAll(@Body FindBody body) {
        return JsonResult.result(ServiceManage.findAll(body.getName()), 200, "");
    }
}
